﻿using Smokey.Client.Contexts;
using System;
using System.ComponentModel;
namespace Smokey.Client.Screens {
   internal class ViewModelBase : INotifyPropertyChanged {
       private readonly ViewModelContext context;

       public event PropertyChangedEventHandler PropertyChanged;

       public ViewModelBase(ViewModelContext context) {
           this.context = context;
       }

       public ViewModelContext Context {
           get {
               if (context == null) {
                   throw new InvalidOperationException("Context has not yet been set");
               }
               return context;
           }
       }

       public void OnPropertyChanged(string name) {
           PropertyChangedEventHandler handler = PropertyChanged;
           if (handler != null) {
               handler(this, new PropertyChangedEventArgs(name));
           }
       }
}
}
